//
//  CQImageCardCollectionView.swift
//  TSListDemo
//
//  Created by qian on 2020/11/16.
//  Copyright © 2020 dvlproad. All rights reserved.
//

import Foundation

class CQImageCardCollectionView: CQBaseCardCollectionView {
    override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
        super.init(frame: frame, collectionViewLayout: layout)
        
        self.backgroundColor = #colorLiteral(red: 0.9372549057, green: 0.3490196168, blue: 0.1921568662, alpha: 1)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func addDataModels(array: Array<UIImage>) -> Void {
        self.pages += array.count >= limit ? 1 : 0
        synchronized(self.showDataSource) {
            self.allDataSource.append(contentsOf: array)
            if self.pages == 1 {
                if array.count > self.visibleCellsCount {
                    var newArray = [UIImage]()
                    newArray = array[0,1,2,3]
                    self.showDataSource.append(contentsOf: newArray)
                    self.insertIndex = self.visibleCellsCount
                } else {
                    self.showDataSource.append(contentsOf: array)
                    self.insertIndex = 0
                }
            }
        }
        self.reloadData()
    }
}
